package com.fortune.cat.bean;

import com.fortune.cat.enums.RateLimiterEnums;
import com.fortune.cat.enums.RateLimiterKeyResolverEnums;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zhaozeyang
 * @date 2019/4/24 21:39
 * @description
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RequestRateLimiterConfig {


    @ApiModelProperty("对应RouteDefinitionRecipient.qualifiedName")
    private String routeId;

    /**
     * {@link RateLimiterKeyResolverEnums}
     */
    @ApiModelProperty("限流面向的纬度")
    private Integer keyResolverType;

    /**
     * {@link RateLimiterEnums}
     */
    @ApiModelProperty("限流的实现方式；1：redis，2：local")
    private Integer rateLimiterType;

    @ApiModelProperty("允许用户每秒处理多少个请求")
    private Integer replenishRate;

    @ApiModelProperty("令牌桶的容量，允许在一秒钟内完成的最大请求数")
    private Integer burstCapacity;

    private String path;

    private String method;

    private Query query;

    private Header header;


    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    public static class Query {

        private String query;

        private String value;
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    public static class Header {

        private String header;

        private String value;
    }

}
